<template>
<h1>El-表单组件</h1>
  <h1>表单练习</h1>
  <el-form style="width: 500px ;margin: 0 auto;" label-width="80">
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" v-model="user.username"></el-input>
    </el-form-item>


    <el-form-item label="密码">
      <el-input placeholder="请输入密码" show-password type="password" v-model="user.password"></el-input>
    </el-form-item>

    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio-button :label="'男'">男</el-radio-button>
        <el-radio-button :label="'女'">女</el-radio-button>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="所在地" >
      <el-select placeholder="请选择所在地" v-model="user.address">
        <el-option label="北京" value="北京"></el-option>
        <el-option label="上海" value="上海"></el-option>
        <el-option label="广州" value="广州"></el-option>
        <el-option label="深圳" value="深圳"></el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="管理员" v-model="user.isAdmin">
      <el-switch v-model="user.isAdmin" :active-value="true" :inactive-value="false"></el-switch>
    </el-form-item>
  </el-form>
  <el-button type="primary" @click="reg()">点我提交</el-button>

</template>

<script setup>
import {ref} from "vue";
import {ElMessage} from "element-plus";

const arr = ref([]);

const user = ref({
  username: "",
  password: "",
  gender: "",
  address: "",
  isAdmin: false
});
const reg = () => {
  arr.value.push(user.value);
  console.log(arr.value);
//   清空输入框
  user.value = {};
};
const f = (type) => {
  switch (type){
    case 1:
      ElMessage.success('注册成功');
      break;
  }
};

</script>

<style scoped>

</style>